home *** CD-ROM | disk | FTP | other *** search
- unit DrBobSys;
- { a special unit to circumvent SysUtils and get smaller executables }
- interface
-
- function StrPas(Str: PChar): String;
-
- function StrLen(Str: PChar): Cardinal;
-
- function StrToInt(const Str: string): Integer;
-
- function UpperCase(const Str: ShortString): ShortString;
-
- function LowerCase(const Str: ShortString): ShortString;
-
- { WINDOWS APIs }
-
- function GetCommandLine: PChar; stdcall;
- function GetEnvironmentStrings: PChar; stdcall;
- function GetUserName(lpBuffer: PChar; var nSize: Integer): Boolean; stdcall;
-
- var
- StartTime: LongInt = 0;
-
- function timeGetTime: LongInt; stdcall;
-
- implementation
-
- function StrPas(Str: PChar): String;
- begin
- Result := Str;
- end;
-
- function StrLen(Str: PChar): Cardinal; assembler;
- asm
- MOV EDX,EDI
- MOV EDI,EAX
- MOV ECX,0FFFFFFFFH
- XOR AL,AL
- REPNE SCASB
- MOV EAX,0FFFFFFFEH
- SUB EAX,ECX
- MOV EDI,EDX
- end;
-
- function StrToInt(const Str: string): Integer;
- var
- E: Integer;
- begin
- Val(Str, Result, E);
- if E <> 0 then Result := 0
- end;
-
- function UpperCase(const Str: ShortString): ShortString;
- var
- len: Byte absolute Str;
- i: Integer;
- begin
- Result[0] := Str[0];
- for i:=1 to len do
- begin
- Result[i] := Str[i];
- if (Str[i] in ['a'..'z']) then Dec(Result[i],32)
- end
- end;
-
- function LowerCase(const Str: ShortString): ShortString;
- var
- len: Byte absolute Str;
- i: Integer;
- begin
- Result[0] := Str[0];
- for i:=1 to len do
- begin
- Result[i] := Str[i];
- if (Str[i] in ['A'..'Z']) then Inc(Result[i],32)
- end
- end;
-
- function timeGetTime;
- external 'winmm.dll' name 'timeGetTime';
- function GetEnvironmentStrings;
- external 'kernel32.dll' name 'GetEnvironmentStringsA';
- function GetCommandLine;
- external 'kernel32.dll' name 'GetCommandLineA';
- function GetUserName;
- external 'advapi32.dll' name 'GetUserNameA';
- end.
-